
<h1>The <code>json.Unmarshal</code> function accepts case-insensitive object key matches</h1>

<p>For example, the following program prints <code>bar</code>, instead of <code>foo</code>.</p>

<pre><code class="language-Go">package main

import (
	&quot;encoding/json&quot;
	&quot;fmt&quot;
)

type T struct {
	HTML string `json:&quot;HTML&quot;`
}

var s = `{&quot;HTML&quot;: &quot;foo&quot;, &quot;html&quot;: &quot;bar&quot;}`

func main() {
	var t T
	if err := json.Unmarshal([]byte(s), &amp;t); err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(t.HTML) // bar
}
</code></pre>

<p>The docs of the <code>json.Unmarshal</code> function states &quot;preferring an exact match but also accepting a case-insensitive match&quot;. So personally, I think this is a bug in the <code>json.Unmarshal</code> function
implementation, but the Go core team <a href="https://github.com/golang/go/issues/14750">don't think so</a>.</p>

